# 斐波那契数列
def fib(n):
    if n < 2:
        return n
    else:
        return fib(n - 2) + fib(n - 1)

print(fib(14))

# 快排
def quick(qlist):
    if len(qlist) == 0:
        return qlist
    else:
        qb = qlist[0]
        qa = quick([l for l in qlist[1:] if l <= qb])
        qc = quick([ m for m in qlist[1:] if m > qb])
        return qa + [qb] + qc

print(quick([23, 5, 51, 252, 2, 1]))



# 随机插入排序
def inserQuick(qlist):
    for i in range(len(qlist)):
        key = qlist[i]
        j = i - 1
        while j >= 0 and key < qlist[j]:
            qlist[j + 1] = qlist[j]
            j -= 1
            qlist[j + 1] = key
    return qlist


print(inserQuick([23, 512, 2, 32, 11, 212, 54]))

# 99乘法表
def n_n():
    for i in range(1, 10):
        for j in range(1, i + 1):
            print(f'{j}*{i}={j*i} ', end="  ")
        print("\t")


n_n()

# 统计字符串中出现次数最多的字符和次数


# Switch语句


# filter()筛选功能


# map()映射方法


# 获取list索引位置


# 判断字符串中大写的几个，小写的几个


# 修改元组内部元素不可修改的元素

# 列表推导式

# 集合推导式

# 字典推导式
import random


def zdtds():
    list1= random.randint(8,88)
    print("zdddddd", list1)
    # d1 = {i: list1[i] for i in range(len(list1))}
    # print(d1)


zdtds()
# 函数嵌套

# 迭代器
def iterMoudle():
    list1 = [34, 42, 5425, 52]
    li = list1.__iter__()
    print(li.__next__())
    print(li.__next__())
    print(li.__next__())
    print(li.__next__())

    # print(list(list1.__iter__()))

iterMoudle()
# 生成器
def yd():
    list1 = [23, 431, 2, 5]
    yield map(lambda x: x+1, list1)
    cc = 34
    yield cc
print(list(yd().__next__()))


# 装饰器
def wapper(name):
    def inner(*args, **kwargs):
        print("加载游戏外挂")
        play = name(args, kwargs)
        print("卸载游戏外挂")
        return play

    return inner


@wapper  # game = wapper(game)
def game(username, password):
    print(f'登录用户:{username},密码：{password}')



game("zkk", password="123456")
